package com.wc.AlgoOJ_train.train3_算法大礼包.c2_深度优先搜索.AG0302_书架;

import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.io.PrintWriter;
import java.util.StringTokenizer;

/**
 * @Author congge
 * @Date 2024/1/28 15:55
 * @description http://43.138.190.70:8888/p/AG0302
 */
public class Main2 {
    static FastReader sc = new FastReader();
    static PrintWriter out = new PrintWriter(System.out);
    static int N = 20;
    static int[] h = new int[N];
    static int n, b;

    public static void main(String[] args) {
        n = sc.nextInt();
        b = sc.nextInt();
        for (int i = 0; i < n; i++) {
            h[i] = sc.nextInt();
        }
        int res = (int) 1e8;
        for (int i = 0; i < 1 << n; i++) {
            int height = 0;
            for (int j = 0; j < n; j++) {
                if ((i >> j & 1) == 1) {
                    height += h[j];
                }
            }
            if (height >= b) {
                res = Math.min(height - b, res);
            }
        }
        out.println(res);
        out.flush();
    }

    static class FastReader {
        StringTokenizer st;
        BufferedReader br;

        FastReader() {
            br = new BufferedReader(new InputStreamReader(System.in));
        }

        String next() {
            while (st == null || !st.hasMoreElements()) {
                try {
                    st = new StringTokenizer(br.readLine());
                } catch (IOException e) {
                    e.printStackTrace();
                }
            }
            return st.nextToken();
        }

        int nextInt() {
            return Integer.parseInt(next());
        }

        String nextLine() {
            String s = "";
            try {
                s = br.readLine();
            } catch (IOException e) {
                e.printStackTrace();
            }
            return s;
        }

        long nextLong() {
            return Long.parseLong(next());
        }

        double nextDouble() {
            return Double.parseDouble(next());
        }

        // 是否由下一个
        boolean hasNext() {
            while (st == null || !st.hasMoreTokens()) {
                try {
                    String line = br.readLine();
                    if (line == null)
                        return false;
                    st = new StringTokenizer(line);
                } catch (IOException e) {
                    throw new RuntimeException(e);
                }
            }
            return true;
        }
    }
}
